<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
    <title>首页</title>
</head>
<style>
    .class1 {
        background: #444;
        color: #eee;
    }
</style>
<body>
<div id="app">
    {{message}}
</div>


<script>
    var app = new Vue({
        el: '#app',
        data: {
            message: 'Hello World!'
        }
    })
</script>

<div id="app2">
    <br>
    <label for="r1">修改颜色</label>
    <input type="checkbox" v-model="use" id="r1">
    <div v-bind:class="{'class1': use}">
        v-bind:class 指令
    </div>
    <br>
    <div v-if="visible">
        可见的
    </div>
</div>

<script>
    var app2 = new Vue({
        el: '#app2',
        data: {
            use: false,
            visible: false
        }
    });
</script>


<div id="ajax_test">
    <label>Vue Ajax</label>
    <br>
    <input v-on:click="ajax_request" type="button" name="ajax_btn" value="点击加载">
</div>
<script>
    var ajax_app = new Vue({
        el: '#ajax_test',
        methods:{
            ajax_request:function () {
                this.$http.post('/ajax_login', {username:"admin",password:"admin"}, {emulateJSON:true}).then(function(res){
                    document.write(res.body);
                },function(res){
                    console.log(res.status);
                });
            }
        }
    });
</script>
</body>
</html>